package com.leectrl.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class ResponseUtil {
    public static JSONObject responseSuccessMsg(JSONObject jsonObject){
        JSONObject object=new JSONObject();
        object.put("code",0);
        object.put("msg","success");
        if(jsonObject!=null){
            object.put("data",jsonObject);
        }
        return object;
    }

    public static JSONObject responseSuccessMsg(){
        JSONObject object=new JSONObject();
        object.put("code",0);
        object.put("msg","success");
        return object;
    }

    public static JSONObject responseSuccessMsg(String data){
        JSONObject object=new JSONObject();
        object.put("code",0);
        object.put("msg","success");
        object.put("data",data);
        return object;
    }

    public static JSONObject responseSuccessMsg(JSONArray arr){
        JSONObject object=new JSONObject();
        object.put("code",0);
        object.put("msg","success");
        object.put("data",arr);
        return object;
    }

    public static JSONObject responseSuccessTableList(JSONArray arr,long count){
        JSONObject object=new JSONObject();
        object.put("code",0);
        object.put("msg","success");
        object.put("data",arr);
        object.put("count",count);
        return object;
    }

    public static JSONObject responseFailureMsg(int code,String message){
        JSONObject object=new JSONObject();
        object.put("code",code);
        object.put("msg",message);
        return object;
    }

    public static String responseFailureAuthMsg(){
        JSONObject object=new JSONObject();
        object.put("code",-99);
        object.put("msg","登录认证过期");
        return JSON.toJSONString(object);
    }
}
